package com.ushine.common.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component("myMetaObjectHandler")
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject,"createTime", Date.class,new Date());
        this.strictInsertFill(metaObject,"createUser", String.class,"admin_insert");
        this.strictInsertFill(metaObject,"lastUpdateTime", Date.class,new Date());
        this.strictInsertFill(metaObject,"lastUpdateUser", String.class,"admin_insert");
        this.strictInsertFill(metaObject,"flag",Integer.class,0);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.strictUpdateFill(metaObject,"lastUpdateTime",Date.class,new Date());
        this.strictUpdateFill(metaObject,"lastUpdateUser",String.class,"admin_update");
    }
}
